import {
	request_post
} from './respones.js'


// 获取产品列表 所有
export const getChangGuanList = () => {
	return request_post("/yumao_send_user", null)
}

// 搜索api
export const searchChangGuanList = (name) => {
	return request_post("/yumao_send_user", {
		'changguan_name': name
	})
}

// 获取对应场馆的场地列表
export const getChangdiList = (id, openid) => {
	return request_post("/search_booking_backend", {
		'id': id,
		'openid': openid
	})
}

// 场地预约api
export const getYuyueApi = (yuyueList) => {
	return request_post('/create_booking_record', {
		'yuyue_ids': yuyueList
	})
}

// 获取对应场地预约信息的api
export const getYuyueList = (id) => {
	return request_post('/search_booking_record', {
		'id': id
	})
}

// 获取openid 同时获取支付参数 微信支付
export const getPay = (data, payCheck) => {
	return request_post('/get_user_openid', {
		'chang_di_id': data.changdi,
		'yuyue_ids': data.yuyueList,
		'code': data.code,
		'description': data.miaoshu,
		'pay_way': payCheck,
		'changguan_id': data.changguanId,
	})
}

export const getVipyuePay = (data, payCheck) => {
	return request_post('/get_user_openid', {
		'chang_di_id': data.changdi,
		'yuyue_ids': data.yuyueList,
		'code': data.code,
		'description': data.miaoshu,
		'pay_way': payCheck,
		'changguan_id': data.changguanId,
		'appointment_person': data.appointment_person,
		'appointment_phone': data.appointment_phone
	})
}



// 支付成功反馈
export const returnPayMessage = (payData) => {
	return request_post('/wechatpay_retrun', {
		'changdi_id': payData.changdi,
		'out_trade_no': payData.dingdanhao,
		'money': payData.money,
		'yuyue_ids': payData.yuyueList,
		'timeutc': payData.timeutc,
		'description': payData.miaoshu,
		"appointment_phone": payData.appointment_phone,
		"appointment_person": payData.appointment_person,
		'open_id': payData.openid
	})
}

// 支付失败反馈
export const returnPayMessageFail = (yuyueids) => {
	return request_post('/wechatpay_retrun_fail', {
		'yuyue_ids': yuyueids
	})
}

// 获取微信记录支付列表
export const getPayHistoryList = (openid) => {
	return request_post('/search_booking_consumption', {
		"open_id": openid
	})
}

// 获取会员充值记录
export const getVipPayHistoryList = (openid, changuanid) => {
	return request_post('/search_booking_consumption', {
		"open_id": openid,
		'changuan_id': changuanid
	})
}

// 获取openid 
export const getOpenId = (code) => {
	return request_post('/get_openid', {
		'code': code
	})
}

// 根据时间空闲时间的场地
export const getFreeTime = (day, startTime, endTime, id) => {
	return request_post('/search_booking_backend', {
		'id': id,
		'start_time': startTime,
		'end_time': endTime,
		'day': day
	})
}

// 查看会员卡 和余额
export const getVipCard = (openid) => {
	return request_post('/search_records_of_consumption', {
		'open_id': openid
	})
}



// 会员卡充值预处理
export const getVipPay = (changguanId, total, code, miaoshu) => {
	return request_post('/search_recharge_member', {
		'changguan_id': changguanId,
		'total_no': total,
		'openid': code,
		"description": miaoshu
	})
}

// 返回充值成功
export const retunVipPay = (openId, changguanId, money, time, dingdanhao, miaoshu) => {
	return request_post('/create_or_search_member', {
		'open_id': openId,
		'changguan_id': changguanId,
		'total_no': money,
		'timeutc': time,
		'out_trade_no': dingdanhao,
		'description': miaoshu
	})
}

// 获取预约页面列表
export const getBookingViewList = (id) => {
	return request_post('/search_booking_backend_record', {
		'id': id
	})
}

// 场馆详情 设施
export const getChanguanSheshi = (id) => {
	return request_post('/search_sheshi', {
		'id': id
	})
}

// 获取场馆方组队信息
export const getChanguanZuduiMessage = (id) => {
	return request_post('/da_zu_dui', {
		'changguan_id': id
	})
}

// 加入官方组队
export const getJiaruChangguanZudui = (id, openid) => {
	return request_post('/join_dazudui', {
		'dazudui_record_id': id,
		'open_id': openid,
	})
}


// 退出官方组队
export const getExitChangguanZudui = (id, openid) => {
	return request_post('exit_dazudui', {
		'dazudui_record_id': id,
		'open_id': openid,
	})
}